package com.topscore.uke.mvp.presenters;

import com.topscore.uke.entities.HotWordItem;
import com.topscore.uke.mvp.contractors.GetHotWordContractor;
import com.topscore.uke.mvp.model.GetHotWordModel;
import com.topscore.uke.network.BaseResponse;

import java.util.List;

/**
 * Created by 71468 on 2018/3/20.
 */

public class GetHotWordPresenter implements GetHotWordContractor, GetHotWordContractor.Presenter, GetHotWordContractor.CallBack {
    private View mView;
    private Model mModel = new GetHotWordModel(this);

    public GetHotWordPresenter(View view) {
        this.mView = view;
    }

    @Override
    public void getHotWord() {
        mView.onLoading("");
        mModel.getHotWord();
    }

    @Override
    public void onError(int errorCode, String errorMessage) {
        mView.onFail(errorCode,errorMessage);
    }

    @Override
    public void onComplete() {
        mView.onLoadFinished();
    }

    @Override
    public void onGetHotWordSuccess(BaseResponse<List<HotWordItem>> response) {
        mView.getWordsAdapter().setNewData(response.getData());
    }
}
